package com.explorati.design_pattern.creational.singleton;

/**
 * ThreadLocal线程单例 不能保证全局单例，但能保证线程单例
 * 
 * @author explorati
 *
 */
public class ThreadLocalInstance {

	private static final ThreadLocal<ThreadLocalInstance> threadLocalInstanceThreadLocal = new ThreadLocal<ThreadLocalInstance>() {
		@Override
		protected ThreadLocalInstance initialValue() {
			return new ThreadLocalInstance();
		}
	};

	private ThreadLocalInstance() {

	}

	public static ThreadLocalInstance getInstance() {
		return threadLocalInstanceThreadLocal.get();
	}
}
